package com.wanwu.channel.common.enums;

public enum ChannelClearanceStatus {

    FAIL(0, "申报失败"),
    SUCCESS(1, "申报成功"),
    PROCESSING(2, "申报中"),
    UNDECLARED(3, "未申报"),
    SUBMITTED(4, "申报已提交（订单已经送海关，商户重新申报，并且海关还有修改接口，那么记录的状态会是这个") ,
    EXCEPT(5, "海关接口异常"),
    REJECT(6, "海关退单"),
    UNKNOWN(99, "未知状态"),
    ;


    private Integer value;
    private String desc;

    ChannelClearanceStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static ChannelClearanceStatus valueOf(Integer value) {

        for (ChannelClearanceStatus type : ChannelClearanceStatus.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        return UNKNOWN;
    }

    public static ChannelClearanceStatus getByCode(Integer value){
        for (ChannelClearanceStatus type : ChannelClearanceStatus.values()) {
            if (type.getValue().equals(value)) {
                return type;
            }
        }
        return UNKNOWN;
    }

    public Integer getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static Boolean isFinish(Integer status) {
        if(ChannelClearanceStatus.SUCCESS.getValue().equals(status)){
            return true;
        }
        return false;
    }
}

